package com.poposchool.project.mapper;

import com.poposchool.project.controller.dto.PriceByMonth;
import com.poposchool.project.entity.StoreOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单表 Mapper 接口
 * </p>
 *
 * @author wangjie
 * @since 2022-09-09
 */
public interface StoreOrderMapper extends BaseMapper<StoreOrder> {
    @Select("SELECT sum(pay_price) FROM yx_store_order")
    BigDecimal getAllPrice();

    @Select("SELECT sum(cost) FROM yx_store_order")
    BigDecimal getAllCost();

    @Select("select month(create_time) as month,SUM(pay_price) as price,sum(cost) as cost FROM `yx_store_order`\n" +
            "where year(create_time)=#{year} \n" +
            "GROUP BY MONTH(create_time) \n" +
            "order by month")
    List<PriceByMonth> getAllPriceByMonth(String year);


}
